package main

import (
	"go-mvc-ecommerce/controllers"
	"go-mvc-ecommerce/database"
	"go-mvc-ecommerce/routers"
	"go-mvc-ecommerce/services"
)

func main() {
	// 初始化数据库连接
	database.Connect()

	// 初始化服务层
	userService := services.NewUserService(database.DB)
	productService := services.NewProductService(database.DB)
	orderService := services.NewOrderService(database.DB)

	// 初始化控制器
	userController := controllers.NewUserController(userService)
	productController := controllers.NewProductController(productService)
	orderController := controllers.NewOrderController(orderService)

	// 初始化路由
	router := routers.NewRouter(userController, productController, orderController)
	r := router.SetupRoutes()

	// 启动服务器
	r.Run(":8080")
}
